package com.alibaba.citrus.cr.mn.order.center.facade.function.convert;

import com.epoch.app.crforecastsales.domian.forecastorder.dto.LoadForecastOrderRequest;
import com.epoch.app.crforecastsales.domian.forecastorder.model.ForecastOrder;
import com.epoch.app.crforecastsales.sdo.ForecastOrderSDO;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

public class ForecastOrderSDOToDOConvertor {

    public static ForecastOrder convert(ForecastOrderSDO forecastOrderSDO){
        ForecastOrder forecastOrder = new ForecastOrder();
        forecastOrder.setId(Long.parseLong(forecastOrderSDO.getId()));
        if (StringUtils.isNotBlank(forecastOrderSDO.getReceiveAddressCode())) {
            forecastOrder.setReceiveAddressCode(forecastOrderSDO.getReceiveAddressCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getCustomerCode())) {
            forecastOrder.setCustomerCode(forecastOrderSDO.getCustomerCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getTransportModeCode())) {
            forecastOrder.setTransportModeCode(forecastOrderSDO.getTransportModeCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getChannelCode())) {
            forecastOrder.setChannelCode(forecastOrderSDO.getChannelCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getDepartmentCode())) {
            forecastOrder.setDepartmentCode(forecastOrderSDO.getDepartmentCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getOrganizationCode())) {
            forecastOrder.setOrganizationCode(forecastOrderSDO.getOrganizationCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getSaleChannelCode())) {
            forecastOrder.setSaleChannelCode(forecastOrderSDO.getSaleChannelCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getCreditBalance())) {
            forecastOrder.setCreditBalance(forecastOrderSDO.getCreditBalance());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getProductGroupCode())) {
            forecastOrder.setProductGroupCode(forecastOrderSDO.getProductGroupCode());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getCreateReason())) {
            forecastOrder.setCreateReason(forecastOrderSDO.getCreateReason());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getWareHouseCode())) {
            forecastOrder.setWareHouseCode(forecastOrderSDO.getWareHouseCode());
        }

        if (StringUtils.isNotBlank(forecastOrderSDO.getWareHouseName())) {
            forecastOrder.setWareHouseName(forecastOrderSDO.getWareHouseName());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getCustomerReferenceNo())) {
            forecastOrder.setCustomerReferenceNo(forecastOrderSDO.getCustomerReferenceNo());
        }
        forecastOrder.setRemark(forecastOrderSDO.getRemark());
        forecastOrder.setAddRemark(forecastOrderSDO.getAddRemark());
        if (null != forecastOrderSDO.getCustomerExpectTDate()) {
            forecastOrder.setCustomerExpectTDate(forecastOrderSDO.getCustomerExpectTDate());
        }
        if (null != forecastOrderSDO.getVaildBeginTime()) {
            forecastOrder.setVaildBeginTime(forecastOrderSDO.getVaildBeginTime());
        }
        if (StringUtils.isNotBlank(forecastOrderSDO.getModifierId())) {
            forecastOrder.setModifierId(forecastOrderSDO.getModifierId());
        }

        if (StringUtils.isNotBlank(forecastOrderSDO.getModifierCode())) {
            forecastOrder.setModifierCode(forecastOrderSDO.getModifierCode());
        }

        if (StringUtils.isNotBlank(forecastOrderSDO.getModifierName())) {
            forecastOrder.setModifierName(forecastOrderSDO.getModifierName());
        }

        if (Objects.nonNull(forecastOrderSDO.getGmtModified())) {
            forecastOrder.setGmtModified(forecastOrderSDO.getGmtModified());
        }
        LoadForecastOrderRequest loadForecastOrderRequest1 = new LoadForecastOrderRequest();
        loadForecastOrderRequest1.setId(forecastOrderSDO.getId());
        forecastOrder.setStatus(forecastOrderSDO.getStatus());
        return forecastOrder;
    }
}
